function Config(){
    this.releaseAllLevelsFree = true;
    this.throughLevel = false;//直达某一关
    this.designWidth = 640;
    this.designHeight = 960;
    this.kLanguages = ['en', 'zh-Hans', 'zh-Hant', 'ja', 'ko', 'ar']
}

var config = new Config();

Config.prototype.init = function(){
    if (!storage.get("SOUND")) {
        storage.set("SOUND", true);
    }
    storage.set("LEVEL_MAX_TIME", 120);
    
    storage.set("IAP_LEVEL", 120);//total level num
    storage.set("IAP_LEVEL_FREE", 40);//free level num
    storage.set("IAP_LEVEL_FREE_2", 60);
    storage.set("IAP_LEVEL_FREE_3", 80);
    storage.set("IAP_LEVEL_FREE_4", 100);
    
    if (!parseInt(storage.get("nextUnpassLevel"))) {
        storage.set("nextUnpassLevel", 1);
    }
    storage.set("unlockState", 0);
    storage.set("score", 100);
    storage.set("unlockedLevel", parseInt(storage.get('IAP_LEVEL_FREE')));
    storage.set("bucks", 0);
    
    if (config.releaseAllLevelsFree) {
        storage.set('unlockState', 4)
        storage.set('unlockedLevel', parseInt(storage.get('IAP_LEVEL')))
    }
    cc.log(config.getCurrentLanguage())
    util.i18n.setLanguage(config.getCurrentLanguage());
}

Config.prototype.hasPlayedLevelOne = function(){
    return parseInt(storage.get('nextUnpassLevel')) > 1;
}

Config.prototype.nextUnpassLevel = function(){
    return parseInt(storage.get("nextUnpassLevel"));
}

Config.prototype.getCurrentLanguage = function(){
    if (storage.get('currentLanguage')) {
        return config.kLanguages[parseInt(storage.get('currentLanguage'))];
    } else {
        return navigator.language;
    }
}

Config.prototype.getCurrentLanguageIndex = function(){
    var cur = 0;
    for (i in config.kLanguages) {
        if (config.kLanguages[i] == config.getCurrentLanguage()) {
            cur = i;
        }
    }
    return cur;
}

Config.prototype.setCurrentLanguage = function(lang){
    storage.set('currentLanguage', lang);
}

config.init();
